import Render3DText from './lib/render-3d-text.js';
 
import * as THREE from 'three';




const config = {
  "materials": [
      /*所以材质可以定制
              说了呀 所以材质可以定制 参数也是 THREE参数位置配置的
              MeshPhysicalMaterial
              MeshToonMaterial
              MeshPhongMaterial
              MeshLambertMaterial
              MeshStandardMaterial
              MeshBasicMaterial
              */
  
    {
      "type": "MeshBasicMaterial",
      "color": 0x000000,
      "transparent": true,
      "opacity": 0.4,
      "depthWrite": false
    },{
      "type": "MeshPhongMaterial",
      "color": 0xffb6c1,
      "specular": 0xffffff,
      "shininess": 30,
      "transparent": false,
      "opacity": 1.0
    }
  ],
  "lights": [
      /*所有灯光可以定制 参数也是 THREE参数位置配置的
           ambientLight
           pointLight
           directionalLight
           
           */
    {
      "type": "DirectionalLight",
      "color": 0xffffff,
      "intensity": 1.5,
      "position": { "x": -0.8, "y": 1.2, "z": 1.5 },
      "castShadow": true,
      "shadow": {
        "mapSize": { "width": 2048, "height": 2048 },
        "bias": -0.001
      }
    },
    {
      "type": "AmbientLight",
      "color": 0x404040,
      "intensity": 0.3
    }
  ],
  "geometry": {
    "type": "TextGeometry",
    "parameters": {
      "bevel": {
        "enabled": true,
        "size": 12,
        "thickness": 16,
        "segments": 150,
        "angle": 0.5,
        "curveSegments": 2
      },
      "depth": 8,
      "steps": 2
    }
  },
  "text": {
    "fontName": "Rounded",
    "fontSize": 140,
    "content": "ABC",
    "charSpacing": 5,
    "lineSpacing": 0,
    "pathOffset": -10
  },
  "camera": {
    /*['Orthographic','Perspective']*/
    "type": "Perspective",
    "perspective": {
      "fov": 45,
      "near": 0.1,
      "far": 3000,
      "position": { "x": 0, "y": 0, "z": 1200 }
    },
    "orthographic": {
      "viewSize": 1000,
      "near": 0.1,
      "far": 3000,
      "position": { "x": 0, "y": 0, "z": 1500 }
    }
  },
  "scene":{
    background: { color: 0x000123 },
    fog: { color: 0xfffabc ,
      near:250,
      
      far:1400,
    },
  },
  "render": {
    "autoClip": true, 
    "antialias": true
  }
};

const config1 ={
  "materials": [
    {
      "type": "MeshPhysicalMaterial",
      "color": 0xFFD700,
      "metalness": 0.8,
      "roughness": 0.3,
      "clearcoat": 0.5,
      "transparent": false,
      "opacity": 1.0
    },
    {
      "type": "MeshBasicMaterial",
      "color": 0x333333,
      "transparent": true,
      "opacity": 0.3,
      "depthWrite": false
    }
  ],
  "lights": [
    {
      "type": "DirectionalLight",
      "color": 0xFFEECC,
      "intensity": 1.8,
      "position": { "x": -1.2, "y": 2.0, "z": 2.0 },
      "castShadow": true,
      "shadow": {
        "mapSize": { "width": 4096, "height": 4096 },
        "bias": -0.0001
      }
    },
    {
      "type": "HemisphereLight",
      "color": 0x445588,
      "groundColor": 0x223344,
      "intensity": 0.5
    }
  ],
  "geometry": {
    "type": "TextGeometry",
    "parameters": {
      "bevel": {
        "enabled": true,
        "size": 10,
        "thickness": 14,
        "segments": 48,
        "angle": 0.6,
        "curveSegments": 4
      },
      "depth": 12,
      "steps": 3
    }
  },
  "text": {
    "fontName": "GoldDeco",
    "fontSize": 160,
    "content": "GOLD",
    "charSpacing": 8,
    "lineSpacing": 0,
    "pathOffset": -15
  },
  "camera": {
    "type": "Perspective",
    "perspective": {
      "fov": 50,
      "near": 0.1,
      "far": 5000,
      "position": { "x": 0, "y": 80, "z": 800 }
    }
  },
  "scene": {
    "background": {
      "type": "Cubemap",
      "files": [
        "px.jpg", "nx.jpg",
        "py.jpg", "ny.jpg",
        "pz.jpg", "nz.jpg"
      ]
    },
    "fog": {
      "color": 0x334455,
      "near": 300,
      "far": 2000
    }
  },
  "postprocessing": {
    "SSAO": {
      "radius": 0.5,
      "intensity": 1.2
    },
    "Bloom": {
      "strength": 0.8,
      "threshold": 0.6
    }
  }
}
 
config.text.ttfUrl = "/static/fonts/super-bubble.ttf";

new Render3DText(
  config
)